package com.web.quartz.service.impl;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.web.basic.service.impl.ElasticsearchServiceImpl;
import com.web.common.basic.elasticsearch.entity.ElasticIndices;
import com.web.common.result.R;
import com.web.service.handler.error.CustomException;

import lombok.extern.slf4j.Slf4j;

/**
 * 此类专门用于测试定时任务执行的具体类
 * @author zhouhui
 * @since 1.0.0
 */
@Slf4j
public class TestJob extends QuartzJobBean{
	
	@Autowired
	private ElasticsearchServiceImpl elasticsearchServiceImpl;

	@Override
	protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
		log.info(context.getJobDetail().getKey().getName());
		R<List<ElasticIndices>> a = elasticsearchServiceImpl.getIndexList();
		log.info(a.getCode());
		String curDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
		log.info("------  已经开始执行定时任务测试类，当前时间"+ curDate + "  ------");
		throw new CustomException("测试异常信息");
	}

}
